<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
				xmlns:ui="http://java.sun.com/jsf/facelets"
				xmlns:h="http://java.sun.com/jsf/html"
				xmlns:a4j="http://richfaces.org/a4j"
				xmlns:rich="http://richfaces.org/rich"
				xmlns:f="http://java.sun.com/jsf/core"
				xmlns:c="http://java.sun.com/jstl/core"
				xmlns:t="http://myfaces.apache.org/tomahawk"
				template="/pages/search_template.xhtml"> 

	<ui:param name="crudBean" value="#{headerArquivoRemessaVendasBean}" />
	
	<ui:define name="saveStateObjectsDefined">
		<t:saveState value="#{crudBean.listaEstLojas}" />
		<t:saveState value="#{crudBean.listaBandeiras}" />
		<t:saveState value="#{crudBean.listaProdutos}" />
		<t:saveState value="#{crudBean.exibirListaLojas}" />
	</ui:define>
	
	<ui:define name="requiredFieldsMessage">
		<h:outputText value="#{bundle.peloMenosUmDosCamposObrigatorios}" rendered="#{crudBean.searching}"/>
	</ui:define>
	
	<ui:define name="content">
		<!-- Painel de Pesquisa - Inicio -->
		<h:panelGroup id="panelGroupDePesquisa" rendered="#{crudBean.searching}">
			<f:subview id="viewBusca">
				<table>
					<tr>
						<td class="tdCor"><h:outputText value="#{bundle.lbl_periodo_importacao}"/> *</td>
						<td class="tdBranco">
							<rich:calendar value="#{crudBean.searchObject.filtro.dataImportacaoInicial}" datePattern="dd/MM/yyyy" cellWidth="24px" cellHeight="22px" style="width:200px" showWeeksBar="false" inputSize="10" converter="dataConverter" oninputkeypress="formataData(this, event);" maxlength="10" onkeypress="soNumero(this);" enableManualInput="true"/>
							<h:outputText value=" #{bundle.lbl_ate} "/>
							<rich:calendar value="#{crudBean.searchObject.filtro.dataImportacaoFinal}" datePattern="dd/MM/yyyy" cellWidth="24px" cellHeight="22px" style="width:200px" showWeeksBar="false" inputSize="10" converter="dataConverter" oninputkeypress="formataData(this, event);" maxlength="10" onkeypress="soNumero(this);" enableManualInput="true"/>
						</td>
					</tr>
					<tr>
						<td class="tdCor"><h:outputText value="#{bundle.lbl_periodo_geracao}"/> *</td>
						<td class="tdBranco">
							<rich:calendar value="#{crudBean.searchObject.filtro.dataGeracaoInicial}" datePattern="dd/MM/yyyy" cellWidth="24px" cellHeight="22px" style="width:200px" showWeeksBar="false" inputSize="10" converter="dataConverter" oninputkeypress="formataData(this, event);" maxlength="10" onkeypress="soNumero(this);" enableManualInput="true"/>
							<h:outputText value=" #{bundle.lbl_ate} "/>
							<rich:calendar value="#{crudBean.searchObject.filtro.dataGeracaoFinal}" datePattern="dd/MM/yyyy" cellWidth="24px" cellHeight="22px" style="width:200px" showWeeksBar="false" inputSize="10" converter="dataConverter" oninputkeypress="formataData(this, event);" maxlength="10" onkeypress="soNumero(this);" enableManualInput="true"/>
						</td>
					</tr>
					<tr>
						<td class="tdCor"><h:outputText value="#{bundle.lbl_periodo_vendas}"/> *</td>
						<td class="tdBranco">
							<rich:calendar value="#{crudBean.searchObject.filtro.dataVendaInicial}" datePattern="dd/MM/yyyy" cellWidth="24px" cellHeight="22px" style="width:200px" showWeeksBar="false" inputSize="10" converter="dataConverter" oninputkeypress="formataData(this, event);" maxlength="10" onkeypress="soNumero(this);" enableManualInput="true"/>
							<h:outputText value=" #{bundle.lbl_ate} "/>
							<rich:calendar value="#{crudBean.searchObject.filtro.dataVendaFinal}" datePattern="dd/MM/yyyy" cellWidth="24px" cellHeight="22px" style="width:200px" showWeeksBar="false" inputSize="10" converter="dataConverter" oninputkeypress="formataData(this, event);" maxlength="10" onkeypress="soNumero(this);" enableManualInput="true"/>
						</td>
					</tr>
					<tr>
						<td class="tdCor" width="20%"><h:outputText value="#{bundle.lbl_loja}"/></td>
						<td class="tdBranco">
							<h:selectOneMenu rendered="#{crudBean.exibirListaLojas}" value="#{crudBean.searchObject.filtro.estLoja}" converter="simpleIndexConverter">
    							<t:selectItems var="o" itemValue="#{o.codigo}" itemLabel="#{o.descricao}" value="#{crudBean.listaEstLojas}" />
    						</h:selectOneMenu>
    						<h:outputText rendered="#{!crudBean.exibirListaLojas }" value=" #{crudBean.searchObject.filtro.nomeEstLoja} "/>
						</td>
					</tr>
					<tr>
						<td class="tdCor" width="25%"><h:outputText value="#{bundle.lbl_bandeira}"/></td>
						<td class="tdBranco">
							<h:selectOneMenu value="#{crudBean.searchObject.filtro.bandeira}" converter="simpleIndexConverter">
    							<t:selectItems var="o" itemValue="#{o.codigo}" itemLabel="#{o.descricao}" value="#{crudBean.listaBandeiras}" />
								<a4j:support event="onchange" reRender="panelGroupDePesquisa" actionListener="#{crudBean.setarListaProdutos}"/>
    						</h:selectOneMenu>
						</td>
					</tr>
					<tr>
						<td class="tdCor" width="25%"><h:outputText value="#{bundle.lbl_produto}"/></td>
						<td class="tdBranco">
							<h:selectOneMenu value="#{crudBean.searchObject.filtro.produto}" converter="simpleIndexConverter">
    							<t:selectItems var="o" itemValue="#{o.codigo}" itemLabel="#{o.descricao}" value="#{crudBean.listaProdutos}" />
    						</h:selectOneMenu>
						</td>
					</tr>
					
				</table>
			</f:subview>
		</h:panelGroup>
		<!-- Painel de Pesquisa - Fim -->
		
		<!-- Painel de Visualizacao - Inicio -->
		<h:panelGroup id="panelGroupDeEdicao" rendered="#{crudBean.viewing}">
			<f:subview id="viewEdicao">
				<table>
					<tr>
						<td class="tdCor" width="20%"><h:outputText value="#{bundle.lbl_id}"/></td>
						<td class="tdBranco">
							<h:outputText value="#{crudBean.entity.codigo}"/>
						</td>
					</tr>
					<tr>
						<td class="tdCor"><h:outputText value="#{bundle.lbl_data_geracao}"/></td>
						<td class="tdBranco">
							<h:outputText value="#{crudBean.entity.dataGeracao}"/>
						</td>
					</tr>
					<!-- 
					<tr>
						<td class="tdCor"><h:outputText value="#{bundle.lbl_data_importacao}"/></td>
						<td class="tdBranco">
							<h:outputText value="#{crudBean.entity.dataRecebimento}"/>
						</td>
					</tr>
					-->
					<tr>
						<td class="tdCor"><h:outputText value="#{bundle.lbl_data_venda_inicio}"/></td>
						<td class="tdBranco">
							<h:outputText value="#{crudBean.entity.dataVendaInicio}"/>
						</td>
					</tr>
					<tr>
						<td class="tdCor"><h:outputText value="#{bundle.lbl_data_venda_fim}"/></td>
						<td class="tdBranco">
							<h:outputText value="#{crudBean.entity.dataVendaFinal}"/>
						</td>
					</tr>
					<tr>
						<td class="tdCor"><h:outputText value="#{bundle.lbl_usuario_recebimento}"/></td>
						<td class="tdBranco">
							<h:outputText value="#{crudBean.entity.usuarioRecebimentoVo.nome}"/>
						</td>
					</tr>
					<tr>
						<td class="tdCor"><h:outputText value="#{bundle.lbl_quantidade_registros}"/></td>
						<td class="tdBranco">
							<h:outputText value="#{crudBean.entity.quantidadeRegistros}"/>
						</td>
					</tr>
					<tr>
						<td class="tdCor"><h:outputText value="#{bundle.lbl_valor_registros}"/></td>
						<td class="tdBranco">
							<h:outputText value="#{crudBean.entity.valorRegistros}"/>
						</td>
					</tr>
				</table>
			</f:subview>
		</h:panelGroup>
		<!-- Painel de Visualizacao - Fim -->
	</ui:define>
	
	<ui:define name="list">
		<h:panelGroup id="panelGroupDeListagem" rendered="#{crudBean.searching}">
			<f:subview id="viewListagem">
				<rich:dataTable id="tblData" value="#{crudBean.searchResult}" binding="#{crudBean.tblData}" var="rst" style="width: 100%;" rowClasses="par,impar">
					<rich:column style="text-align: center;" sortBy="#{rst.codigo}">
						<f:facet name="header">
							<h:outputText value="#{bundle.lbl_id}" />
						</f:facet>
						<h:outputText value="#{rst.codigo}"/>
					</rich:column>
					<rich:column style="text-align: center;" sortBy="#{rst.dataGeracao}">
						<f:facet name="header">
							<h:outputText value="#{bundle.lbl_data_geracao}" />
						</f:facet>
						<h:outputText value="#{rst.dataGeracao}"/>
					</rich:column>
					<rich:column style="text-align: center;" sortBy="#{rst.dataVendaInicio}">
						<f:facet name="header">
							<h:outputText value="#{bundle.lbl_data_venda_inicio}" />
						</f:facet>
						<h:outputText value="#{rst.dataVendaInicio}"/>
					</rich:column>
					<rich:column style="text-align: center;" sortBy="#{rst.dataVendaFinal}">
						<f:facet name="header">
							<h:outputText value="#{bundle.lbl_data_venda_fim}" />
						</f:facet>
						<h:outputText value="#{rst.dataVendaFinal}"/>
					</rich:column>
					<rich:column style="text-align: center;" sortBy="#{rst.dataRecebimento}">
						<f:facet name="header">
							<h:outputText value="#{bundle.lbl_data_importacao}" />
						</f:facet>
						<h:outputText value="#{rst.dataRecebimento}"/>
					</rich:column>
					<rich:column style="text-align: center;" sortBy="#{rst.usuarioRecebimentoVo.nome}">
						<f:facet name="header">
							<h:outputText value="#{bundle.lbl_usuario_recebimento}" />
						</f:facet>
						<h:outputText value="#{rst.usuarioRecebimentoVo.nome}"/>
					</rich:column>
					<rich:column style="text-align: center;" sortBy="#{rst.quantidadeRegistros}">
						<f:facet name="header">
							<h:outputText value="#{bundle.lbl_quantidade_registros}" />
						</f:facet>
						<h:outputText value="#{rst.quantidadeRegistros}"/>
					</rich:column>
					<rich:column style="text-align: center;" sortBy="#{rst.valorRegistros}">
						<f:facet name="header">
							<h:outputText value="#{bundle.lbl_valor_registros}" />
						</f:facet>
						<h:outputText value="#{rst.valorRegistros}"/>
					</rich:column>
					<rich:column style="text-align: center;">
						<f:facet name="header">
							<h:outputText value="#{bundle.lbl_visualizar}" />
						</f:facet>
						<a4j:commandLink actionListener="#{crudBean.exibirSelecionado}" ajaxSingle="true" reRender="formulario, panelTitle">
							<h:graphicImage value="/imagens/lupa.jpg" height="20" width="20" style="border: 0px;"/>
						</a4j:commandLink>
					</rich:column>
					
					<f:facet name="footer">
						<rich:columnGroup>
							<rich:column colspan="6" style="text-align: right;">
								<h:outputText value="#{bundle.lbl_total}"/>
							</rich:column>
							<rich:column style="text-align: right;">
								<h:outputText value="#{crudBean.qtdeTotal}"/>
							</rich:column>
							<rich:column style="text-align: right;">
								<h:outputText value="#{crudBean.valorTotal}"/>
							</rich:column>
							<rich:column></rich:column>
						</rich:columnGroup>
					</f:facet>
				</rich:dataTable>
			</f:subview>
		</h:panelGroup>

		<!-- Painel de Visualizacao - Inicio -->
		<h:panelGroup id="panelGroupDeDetalhe" rendered="#{crudBean.viewing}">
			<f:subview id="viewDetail">
				<rich:dataTable id="tblDataDetail" value="#{crudBean.listaDetalhes}" binding="#{crudBean.tblDataDetail}" var="det" style="width: 100%;" rowClasses="par,impar">
					<f:facet name="header">
						<rich:columnGroup>
							<rich:column style="text-align: center;">
								<h:outputText value="#{bundle.lbl_data_venda}" />
							</rich:column>
							<rich:column style="text-align: left;">
								<h:outputText value="#{bundle.lbl_loja}" />
							</rich:column>
							<rich:column style="text-align: left;">
								<h:outputText value="#{bundle.lbl_estabelecimento}" />
							</rich:column>
							<rich:column style="text-align: left;">
								<h:outputText value="#{bundle.lbl_bandeira}" />
							</rich:column>
							<rich:column style="text-align: rigth;">
								<h:outputText value="#{bundle.lbl_nsu}" />
							</rich:column>
							<rich:column style="text-align: rigth;">
								<h:outputText value="#{bundle.lbl_autorizacao}" />
							</rich:column>
							<rich:column style="text-align: rigth;">
								<h:outputText value="#{bundle.lbl_plano}" />
							</rich:column>
							<rich:column style="text-align: rigth;">
								<h:outputText value="#{bundle.lbl_valor_bruto}" />
							</rich:column>
						</rich:columnGroup>
					</f:facet>
					
					<rich:column style="text-align: center;">
						<h:outputText value="#{det.dataVendaVo.data}"/>
					</rich:column>
					<rich:column style="text-align: left;">
						<h:outputText value="#{det.lojaVo.descricao}"/>
					</rich:column>
					<rich:column style="text-align: left;">
						<h:outputText value="#{det.estabelecimento}"/>
					</rich:column>
					<rich:column style="text-align: left;">
						<h:outputText value="#{det.bandeiraVo.descricao}"/>
					</rich:column>
					<rich:column style="text-align: right;">
						<h:outputText value="#{det.nsu}"/>
					</rich:column>
					<rich:column style="text-align: left;">
						<h:outputText value="#{det.autorizacao}"/>
					</rich:column>
					<rich:column style="text-align: right;">
						<h:outputText value="#{det.plano}"/>
					</rich:column>
					<rich:column style="text-align: right;">
						<h:outputText value="#{det.valor}"/>
					</rich:column>
				</rich:dataTable>
			</f:subview>
		</h:panelGroup>

	</ui:define>
	
</ui:composition>